# -*- encoding=utf8 -*-
"""
RedFlag-TC000094   （拍摄进入装饰页）剪辑分割功能
使用分割功能场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()
log("--------------------------------剪辑分割场景--------------------------------------")
"""
拍摄视频进入装饰页
点击剪辑
拖动视频条
获取当前视频条时间
点击分割
获取分割后视频条时长
断言
"""
shooter.enter_photography_decoration_page()
shooter.click_element(edit_button)
sleep(1.0)
shooter.swipe_screen((0.8,0.75),(0.45,0.75))
before_segmentation_text = shooter.get_element_text(edit_total_first_paragraph)
shooter.click_element(edit_segmentation)
after_segmentation_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clipTimeTV"))
shooter.assert_texts_not_equal(before_segmentation_text, after_segmentation_text, "断言失败，分割前后视频条时长一致")

log("--------------------------------剪辑多次分割场景--------------------------------------")
"""
滑动屏幕
点击分割
获取视频条下节点数量
断言
"""
shooter.swipe_screen((0.7,0.75),(0.55,0.75))
shooter.click_element(edit_segmentation)
number = shooter.get_child_count(edit_vdeo_bar)
shooter.assert_texts_equal(number, 5, "断言失败，第二次分割后的节点数量与预期值不符合")

# 关闭应用
stop_app(UGC_package_name)